package com.jintoufs.service.contacts.impl;

import com.jintoufs.dao.contacts.ContactsMapper;
import com.jintoufs.domain.contacts.Contacts;
import com.jintoufs.service.contacts.ContactsService;
import com.jintoufs.util.valid.ValidUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class ContactsServiceImpl implements ContactsService {
    @Resource
    private ContactsMapper contactsMapper;
    @Override
    public void save(Contacts contacts, String id) {
        if (!ValidUtil.isEmpty(id)){
            contacts.setId(id);
            contactsMapper.insertSelective(contacts);
        }else {
            contactsMapper.updateByPrimaryKeySelective(contacts);
        }
    }

    @Override
    public void delete(String id) {
        contactsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Contacts> selectByParam(Map<String, Object> param) {
        return contactsMapper.selectByParam(param);
    }
}
